package com.example.test.agent.controller;

import com.example.test.agent.entity.BaseResult;
import com.example.test.agent.entity.Role;
import com.example.test.agent.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "角色管理API")
@RequestMapping("/role")
public class RoleController {


    @Autowired
    private RoleService roleService;

    @ApiOperation("根据用户ID获取角色列表")
    @GetMapping("/findRoleByUserId")
    public BaseResult<Role> findRoleByUserId(@RequestParam("userId") @ApiParam(name = "userId", value = "用户ID", required = true) Integer userId){
        List<Role> list = roleService.findRoleByUserId(userId);
        return BaseResult.success(list);
    }

}
